import React from 'react';
import InputItem from '../../../components/InputItem';
import {Input,InputNumber, message} from 'antd';
const {TextArea}= Input
class NewProjectOne extends React.Component {
    constructor(props) {
        super(props);
        let storageData = JSON.parse(sessionStorage.getItem('newQcProject_one'))
        this.state = { datas:storageData||{} };
    }
    componentDidMount(){
        this.props.onRef(this)
    }
    handleChange=(datas)=>{
        this.setState({datas})
    }
    saveDatas=()=>{
        let {datas}=this.state
        if(!datas.projectName){
            message.error('请输入项目名称')
            return;
        }
        if(!datas.projectType){
            message.error('请输入项目类别')
            return;
        }
        if(!datas.statusSurvey){
            message.error('请输入现状调查')
            return;
        }
        if(!datas.secectReason){
            message.error('请输入选题理由')
            return;
        }
        if(!datas.targetDescription){
            message.error('请输入目标简述')
            return;
        }
        sessionStorage.setItem('newQcProject_one',JSON.stringify(datas))
        return true

    }
    render() {
        const {datas} = this.state
        const columns=[
            {name:'项目名称',keyName:'projectName',valueType:'text',style:{width:600},value:datas.projectName},
            {name:'项目类别',keyName:'projectType',valueType:'text',style:{width:600},value:datas.projectType},
            {name:'现状调查',keyName:'statusSurvey',valueType:'textArea',style:{width:600},value:datas.statusSurvey},
            {name:'选题理由',keyName:'secectReason',valueType:'textArea',style:{width:600},value:datas.secectReason},
            {name:'目标简述',keyName:'targetDescription',valueType:'textArea',style:{width:600},value:datas.targetDescription},

        ]
        return (
            <div>
                <InputItem columns={columns} onChange={this.handleChange}/>
            </div>
        );
    }
}

export default NewProjectOne;